"""Header_Information
------------------------------------
    File_Name: security
    Author: RR9
    Date: 2024/09/18
    Description: 安全相关功能，密码哈希、JWT令牌和验证等
------------------------------------
"""

from passlib.context import CryptContext

# 密码加密

pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")


def get_password_hash(password: str) -> str:
    """ 密码哈希 """
    return pwd_context.hash(password)


def verify_password(plain_password: str, hashed_password: str) -> bool:
    """ 验证密码 """
    return pwd_context.verify(plain_password, hashed_password)

